<?php

/*
 * Fresns Control Panel (Standalone)
 * Copyright (C) 2021-Present 刘鑫
 * Released under the MIT License.
 */

namespace App\Plugins\FcpApi\TweetStats;

use App\Base\Controllers\BaseAdminController;
use App\Plugins\FcpApi\Base\TweetBaseController;
use Illuminate\Http\Request;

class FsControllerAdmin extends TweetBaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->service = new FsService();
    }

    public function home(Request $request)
    {
        //官方通知
        $notice['title'] = '通知通知';
        $notice['url'] = '/';
        $notice['jump_type'] = '_default';

        $data['notice'] = [$notice];
        $data['user_counts'] = rand(0, 100);
        $data['member_counts'] = rand(0, 100);
        $data['group_counts'] = rand(0, 100);
        $data['post_counts'] = rand(0, 100);
        $data['comment_counts'] = rand(0, 100);
        $data['hashtag_counts'] = rand(0, 100);
        //系统版本
        $data['version'] = 'TweetSNS v1.0.210618';
        $data['is_version'] = false;
        $data['system'] = 'Linux';
        $data['web_environment'] = 'nginx/1.18.0';
        $data['php_version'] = 'v7.4.16';
        $data['sql_version'] = 'mysql/5.7.18-txsql-log';
        $data['sql_size'] = '2 MB';

        //相关链接
        $about['title'] = 'TweetSns 官方网站';
        $about['url'] = '/';
        $about['jump_type'] = '_blank';
        $data['about_url'] = [$about];
        $this->success($data);
    }

    // 验证规则
    public function rules($ruleType)
    {
        $rule = [];

        $config = new FsConfig($this->service->getTable());

        switch ($ruleType) {
            case FsConfig::RULE_STORE:
                $rule = $config->storeRule();
                break;

            case FsConfig::RULE_UPDATE:
                $rule = $config->updateRule();
                break;

            case FsConfig::RULE_DESTROY:
                $rule = $config->destroyRule();
                break;

            case FsConfig::RULE_DETAIL:
                $rule = $config->detailRule();
                break;
        }

        return $rule;
    }
}
